# try-except 案例
"""
try:
  # 可能引发异常的代码
except ExceptionType:
  # 处理该异常的代码
"""


def divide_numbers(dividend, divisor):
    try:
        result = dividend / divisor
        print("The result is %s" % result)
    except ZeroDivisionError:
        print("Error: Division by zero is not allowed.")
    except TypeError:
        print("Error: Invalid operand types for '/' operation.")
    except Exception as e:
        print("Error: %s" % str(e))


# 调用函数并传入参数
divide_numbers(10, 2)  # 这将正常执行并输出结果
divide_numbers(10, 0)  # 这将引发 ZeroDevisionError
divide_numbers(10, "2")  # 这将引发 TypeError
